﻿<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/static/include/top.jsp"%>

<table>
		<tbody>
			<tr>
				<th><img src="${ctx}/static/images/pages/cen/rig/ico_01.png" align="middle">&nbsp;
					<c:if test="${requestScope.checkStatus eq '1'}">已提交上级报表</c:if>
					<c:if test="${requestScope.checkStatus eq '3'}">上级驳回列表</c:if>
					<c:if test="${requestScope.checkStatus eq '5'}">上级终审通过报表</c:if>
				</th>
			</tr>
			<tr class="tab_grey">
				<td>
		<form name="searchForm" action="" method="get">
			<input type="hidden" name="p" value="1" />
			报表制度:
		<select id="typeId" name="typeId" onchange="getVersion($('#typeId').val());"  class="tab_textbut" >
			<option value="">请选择..</option>
			<c:forEach var="sys" items="${requestScope.sysCodeList}">					
                 	<option value="${sys.code}">${sys.codeName}</option>
            </c:forEach>
		</select>
		
		<span class="tab_text">报表版本:</span>
		<select id="versionId" name="versionId" onchange="getRep($('#typeId').val(),$('#versionId').val());"  class="tab_textbut_200" >
			<option value="">请选择..</option>
			<c:forEach var="vs" items="${vsList}">
                   <option value="${vs.id}">${vs.versionSystem}</option>
               </c:forEach>
		</select>
				
		<span class="tab_text">填报报表:</span>
		<select id="reportTypeId" name="reportTypeId" class="tab_textbut_300" >
			<option value="">请选择..</option>
        </select>
		
		<br/>
		
		<span class="tab_text">表号:</span>
		<select id="reportNo" name="reportNo" class="tab_textbut_100" >
			<option value="">请选择..</option>
        </select>
        	
        <span class="tab_text">开始时间:</span>
		<input id="searchDate" name="searchDate" onfocus="WdatePicker()" class="Wdate" value="${formdata.startTime}" type="text"  class="tab_textbut" >
		<span class="tab_text">结束时间：</span>
		<input id="endDate" name="endDate" onfocus="WdatePicker()" class="Wdate" value="${formdata.endTime}" type="text"  class="tab_textbut" >
		
		
		<a class="tab_but" href="#" onclick="searchForm.action='${baseURL}/data/report/list/${requestScope.checkStatus}';searchForm.submit();return false;">查询</a>
		<a class="tab_but" href="#" onclick="clearInput(); return false;">清空结果</a>
			
	</form>

		<iframe name="upload" width="0" height="0" frameborder="0"></iframe>
				
				</td>
			</tr>
		</tbody>
</table>

<c:if test="${empty obj.operationResult}">
	<b>没有符合条件的记录。</b>
</c:if>

<c:if test="${not empty obj.operationResult}">
<table id="listTable">
	<thead>
	    <tr>	    	
	        <th width="15%">数据报表</th>
	        <th width="8%">地区</th>
			<th width="8%">频率</th>
			<th width="8%">频率时段</th>
			<th width="14%">报出时间</th>
			<th width="20%">报表单位</th>
			<th width="10%">填表人</th>
			<th width="10%">审批历史</th>
			<th>操作</th>
	    </tr>
	</thead>
	<tbody>
		<c:forEach var="report" items="${obj.operationResult}">
			<tr>
		      	<td align="left">${report.reportName}</td>
		      	<td align="left">${report.reportCityName}</td>
				<td align="left">${requestScope.reportTimetype[report.reportTimetype]}</td>
				<td align="left">${report.reportYear}年</td>
				<td align="left"><fmt:formatDate value="${report.reportDate}" type="date" dateStyle="default"/></td>
				<td align="left">${report.reportUnit}</td>
				<td align="left">${report.reportFillAdmin}</td>				
				<td align="left"><a href="#" onclick="reportHistoryView('${report.id}', '${report.reportUnit}', '${report.reportName}');">历史</a></td>
				<td align="left"><a href="#" onclick="reportView('${report.reportName}', '${report.id}');">详情</a></td>
			</tr>
		</c:forEach>
	</tbody>
	<tfoot>
		<tr class="tab_grey">
			<td colspan="9" align="center" valign="middle" class="tab_white">
				<div class="pagination"> 
					<%@ include file="../include/listpage2.jsp"%>
				</div>
				<div class="clear"></div>
			</td>
		</tr>
	</tfoot>
</table>
</c:if>
<script language="javaScript">

	//根据报表类型查询报表版本信息和表号信息
	function getVersion(typeId){		
		var versionObj = $("#versionId");
		var reportTypeObj = $("#reportTypeId");
		var reportNoObj = $("#reportNo");		
		
		initSelect(versionObj);	//初始化select
		initSelect(reportTypeObj);	//初始化select
		initSelect(reportNoObj);	//初始化select
		
		if (typeId!=""){
			//查询报表报表信息
			var v_url = "${baseURL}/company/report/queryReportVersion/" + typeId;
			$.ajax({			
				url:v_url,
				type:"post",
				dataType:"json",
				success:function(data){
					$.each(data.operationResult, function(i, item){						
						var selected = "";						
						if ("${param['versionId']}" == item.id){
							selected = "selected";
						}						
						versionObj.append("<option value='" + item.id + "' " + selected + " >" + item.versionSystem + "</option>");
					});
					
					versionObj.change();
				}
			});

			//查询报表表号信息
			var no_url = "${baseURL}/company/report/queryTypeNo/" + typeId;
			$.ajax({			
				url:no_url,
				type:"post",
				dataType:"json",
				success:function(data){
					$.each(data, function(i, item){
						var selected = "";						
						if ("${requestScope.typeNo}" == item.typeNo){
							selected = "selected";
						}	
						reportNoObj.append("<option value='" + item.typeNo + "' " + selected + " >" + item.typeNo + "</option>");
					});
				}
			});
			
		}
	}
	
	//根据报表类型查和报表版本查询所有的报表信息
	function getRep(typeId, versionId){		
		var reportTypeObj = $("#reportTypeId");	
		initSelect(reportTypeObj);	//初始化select
		if (typeId!=""&&versionId!=""){
			var url = "${baseURL}/company/report/queryReportTypesByParam/" + versionId + "/" + typeId;
			$.ajax({			
				url:url,
				type:"post",
				dataType:"json",
				success:function(data){					
					$.each(data, function(i, item){						
						var selected = "";						
						if ("${param['reportTypeId']}" == item.id){
							selected = "selected";
						}						
						reportTypeObj.append("<option value='" + item.id + "' " + selected + ">" + item.typeName + "</option>");
					});
				}
			});
		}
	}	
	
	//初始化select
	function initSelect(s_obj){		
		s_obj.empty();		
		s_obj.append("<option value=''>请选择..</option>");
		
	}
	
	//查看报表审批历史
	function reportHistoryView(reportId, reportUnit, reportName){
		  var title = "查看" + reportUnit + "的" + reportName + "的审批历史";
		  var url = "${baseURL}/data/view?id=" + reportId;
		  openWin(title, url, "800", "460");
	}
	
	//查看报表详情
	function reportView(reportName, reportId){
		var userId = "${sessionScope.user.id}";
		var title = reportName + "详情";
		var url = "${baseURL}/reports/service.do?method=showReportInfo&reportOperatorId=" + userId + "&reportId=" + reportId;
		openWin(title, url, "1000", "560");
	}

	function clearInput() {
		$("form input,form select").each(function(){
			this.value = "";
		});
		
		$("#listTable > tbody").html("");
		$("#listTable > tfoot").html("");
	}
	
	/**************************初始化查询参数****************************/
	$("#typeId").val("${param['typeId']}");	
	if ($("#typeId").val() != ""){
		getVersion($("#typeId").val());
	}

	if ("${param['versionId']}" != ""){
		getRep($("#typeId").val(), "${param['versionId']}");
	}

	$("#reportTypeId").val("${param['reportTypeId']}");	
	$("#searchDate").val("${param['searchDate']}");
	$("#endDate").val("${param['endDate']}");
	/**************************初始化查询参数****************************/
</script>

<%@ include file="/static/include/bottom.jsp" %>